<div class="layui-form" lay-filter="form-list" id="form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="required">*</span>标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value="{$data['title']}" disabled>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><span class="required">*</span>推送对象</label>
        <div class="layui-input-block">
            <select name="role_id"  lay-verify="required" id="role_id" disabled>
                <option value="">推送对象</option>
                {foreach $role as $k => $v}
                <option value="{$v['id']}" <?=$data['role_id']==$v['id']?'selected':''?>>{$v['name']}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="required">*</span>是否发送短信</label>
        <div class="layui-input-block">
            <input type="checkbox" name="is_sms" lay-skin="switch" lay-text="是|否"  value="1" <?=$data['is_sms']==1?"checked":''?> disabled>
        </div>
    </div>
    <div class="layui-col-sm12">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>内容</label>
            <div class="layui-input-block">
                <textarea id="content" style="display: none;" name="content" >{$data['content']}</textarea>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="form-submit" id="form-submit" value="确认添加">
    </div>
</div>
<script>
    //Demo
    layui.use(['form','layedit'], function(){
        var form = layui.form
            ,layedit = layui.layedit
        ;

        // 富文本编辑器
        layedit.set({
            uploadImage: {
                url: "{:url('upload/layuiUploads')}" //接口url
            }
        });
        var content = layedit.build('content');

        //监听提交
        form.on('submit(form-submit)', function(data){
            var field = data.field; //获取提交的字段
              field.content = layedit.getContent(content);
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.post("{:url('admin/notice/save')}",field,function (ret) {
                if (ret.code == 0){
                    layer.msg(ret.msg,{icon:6,time:1000},function () {
                        parent.layui.table.reload('demo'); //重载表格
                        parent.layer.close(index); //再执行关闭
                    })
                }else{
                    layer.msg(ret.msg,{icon:5,time:1000})
                }
            });

            return false;
        });
    });


</script>